
#include <vector>

#include <glm/glm.hpp>

struct Rect
{
public:
	glm::vec3 minPos;
	glm::vec3 maxPos;

	Rect(glm::vec3 &minp, glm::vec3 &maxp){
		minPos = minp;
		maxPos = maxp;

		// Swap xmin, zmin if wrong order
		if( minPos[0] > maxPos[0] ){
			float tmp = minPos[0];
			minPos[0] = maxPos[0];
			maxPos[0] = tmp;
		}

		if( minPos[2] > maxPos[2] ){
			float tmp = minPos[2];
			minPos[2] = maxPos[2];
			maxPos[2] = tmp;
		}

	}

	float getWidth()
	{
		return maxPos[0] - minPos[0];
	}

	float getLength()
	{
		return maxPos[2] - minPos[2];
	}

	glm::vec3 getCenter()
	{
		return glm::vec3( minPos[0] + getWidth() / 2.0f , minPos[1], minPos[2]+ getLength() / 2.0f  );
	}

};

class LevelEditor
{
public:
	static LevelEditor* Instance();
	void setCursorPos( glm::vec3 &pos );
	void createNavRect( glm::vec3 &pos );
	void render();

private:
	static LevelEditor* _instance;
	LevelEditor();
	void saveToFile();
	void loadFromFile();
	

	bool startedRect;
	glm::vec3 startPoint;
	glm::vec3 cursorPos;
	std::vector<Rect> navRectList;
};